#include "pch.h"
#include "Renderer.h"
#include "GLShader.h"
namespace HS {
	Render::SceneData* Render::s_SceneData = new Render::SceneData();
	
	void Render::Init()
	{
		RenderCommand::Init();
	}

	void Render::OnWindowResize(uint32_t width, uint32_t height)
	{
		RenderCommand::SetViewport(0, 0, width, height);
	}

	void Render::BeginScene(OrthoCamera& camera)
	{
		s_SceneData->ViewProjectionMatrix = camera.GetViewProjectionMatrix();
	}
	void Render::EndScene()
	{

	}
	void Render::Submit(const std::shared_ptr<Shader>& shader,
		const std::shared_ptr<VertexArray>& vertexArray,const glm::mat4& transform)
	{
		shader->Bind();
		std::dynamic_pointer_cast<GLShader>(shader)->SetMat4("VP",s_SceneData->ViewProjectionMatrix);
		std::dynamic_pointer_cast<GLShader>(shader)->SetMat4("Transform", transform);
		vertexArray->Bind();
		RenderCommand::DrawIndexed(vertexArray);
	}
}